package com.hucheng.activity.entity;

import com.hucheng.activity.dto.ExchangeDTO;
import com.hucheng.activity.dto.LuckPrizeDTO;
import lombok.Data;
import org.apache.commons.lang3.StringUtils;

import java.sql.Timestamp;
import java.util.Date;

/**
 * @Author: 凉白开不加冰
 * @Version: 0.0.1V
 * @Date: 2019-07-15
 * @Description: 持久层数据
 **/
@Data
public class ExchangeDO {
    private Integer exchangeConfigId;
    private String exchangeConfigName;
    private Integer status;
    private Date dateStart;
    private Date dateEnd;
    private String exchangeRemark;
    private Timestamp dateCreated;
    private Timestamp dateUpdated;
    private Integer isDel;

    public static ExchangeDO buildExchangeDO(final ExchangeDTO exchangeDTO) {
        if (exchangeDTO != null) {
            ExchangeDO exchangeDO = new ExchangeDO();
            Timestamp currentTime = new Timestamp(System.currentTimeMillis());
            if (StringUtils.isNotEmpty(exchangeDTO.getExchangeConfigId()+"")) {
                exchangeDO.setExchangeConfigId(exchangeDTO.getExchangeConfigId());
                exchangeDO.setDateCreated(currentTime);
            }else{
                exchangeDO.setDateUpdated(currentTime);
            }
            exchangeDO.setExchangeConfigName(exchangeDTO.getExchangeConfigName());
            exchangeDO.setStatus(exchangeDTO.getStatus());
            exchangeDO.setDateStart(exchangeDTO.getDateStart());
            exchangeDO.setDateEnd(exchangeDTO.getDateEnd());
            exchangeDO.setExchangeRemark(exchangeDTO.getExchangeRemark());
            exchangeDO.setIsDel(exchangeDTO.getIsDel());
            return exchangeDO;
        }
        return null;
    }
}
